
<template>
  <van-overlay :show="routerShow">
    <van-loading />
  </van-overlay>
  <router-view />
</template>

<script lang="ts" setup>
import { getCurrentInstance, ref } from "vue";
import { watch } from "vue-demi";
import { useRouter } from "vue-router";
import { metaMaskMode } from "@/store/metamask";
import getAbis from "@/contract/index";

const metaMaskStore = metaMaskMode();
const router = useRouter();
const routerShow = ref(false);
const { proxy } = getCurrentInstance() as any;

watch(
  () => router,
  () => {
    routerShow.value = true;

    setTimeout(() => {
      routerShow.value = false;
    }, Number(process.env.VUE_APP_ROUTER_LOADING_TIME));
  },
  { deep: true }
);

proxy.$metaMask.init().then(() => {
  proxy.$metaMask.getContract(metaMaskStore.getWeb3(), getAbis());
});
</script>

<style lang="less">
@import "./css/index.less";

#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: @theme-color;
}

.van-overlay {
  .flex-center();
}
</style>
